package com.dailyblue.project.estate.repair.controller;

import com.dailyblue.project.estate.commons.bean.Repair;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.repair.service.RepairService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/repair")
public class RepairController {
    @Resource
    private RepairService repairService;

    @PostMapping
    public JsonResult save(Repair repair) {
        return repairService.addRepair(repair);
    }

    @GetMapping("/findOne/{id}")
    public JsonResult findOne(@PathVariable("id") String repairId) {
        return repairService.findOneRepair(repairId);
    }

    @GetMapping
    public JsonResult findAll() {
        return repairService.findAllRepairs();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult delete(@PathVariable("id") String repairId) {
        return repairService.deleteRepair(repairId);
    }

    @PutMapping("/update")
    public JsonResult update(Repair repair) {
        return repairService.updateRepair(repair);
    }

}
